﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimpleCADControl
{
    public partial class CamForm : Form
    {
        public struct Resolution
        {
            public int Width;
            public int Height;
        }

        public IEnumerable<String> Cameras
        {
            get
            {
                foreach(var obj in comboBoxCams.Items)
                {
                    yield return obj.ToString();
                }
            }
            set
            {
                comboBoxCams.Items.Clear();
                comboBoxCams.Items.AddRange(value.ToArray<String>());
                comboBoxCams.SelectedIndex = 0;
            }

        }

        public Resolution Res { get; set; }

        public int CamIndex
        {
            get;
            set;
        }

        public CamForm()
        {
            InitializeComponent();
            CamIndex = -1;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            CamIndex = comboBoxCams.SelectedIndex;
            Res = new Resolution
            {
                Width =
                    (int)numericUpDownResLow.Value,
                Height =
               (int)numericUpDownResHigh.Value
            };
            this.Close();
        }
    }
}
